<template>
	<page-meta :root-font-size="`${fontSize}px`"></page-meta>
	<scroll-view scroll-y style="height:100vh">
		<view class="item" v-for="item in someList" :key="item.id" @click="vancellClick(item.url)">
			<view class="item_left">
				<view class="item_left_text">
					{{item.text}}
				</view>
				<view class="item_left_time">2020-03-10</view>
			</view>
			<view class="item_right">
				<image class="img" :src="item.header" mode=""></image>
			</view>
		</view>
	</scroll-view>
</template>

<script>
import { mapState } from 'vuex'
	export default {
		computed: {
			...mapState(['fontSize'])
		},
		data() {
			return {
				someList: [{
					id: 1,
					text: "《新型冠状病毒肺炎健康教育手册（第二版）》发布,普及防控知识，提高公众防控意识和能力，是打赢新型冠状病毒肺炎疫情阻击战的重要保障之一。",
					header: "http://www.gov.cn/fuwu/2020-03/10/5489535/images/6667c9220fcb428aa513786808b00b93.jpg",
					url: "http://www.gov.cn/fuwu/2020-03/10/5489535/files/a3e521acbbb84e82a132c4f15b569470.pdf"
				}, ]
			}
		},
		onLoad() {

		},
		methods: {
			vancellClick(e) {
				console.log(e)
				this.getFile(e)
			},
			getFile(e) {
				wx.downloadFile({
					url: e,
					success: function(res) {
						console.log(res)
						var Path = res.tempFilePath //返回的文件临时地址，用于后面打开本地预览所用
						wx.openDocument({
							filePath: Path,
							success: function(res) {
								console.log(res)
								console.log('打开文档成功')
							}
						})
					},
					fail: function(res) {
						console.log(res)
					}
				})



			}
		}
	}
</script>

<style lang="scss" scoped>
	* {
		padding: 0rpx;
		margin: 0rpx;
	}

	page {
		height: 100vh;
	}

	.item {
		// height: 15vh;
		width: 100%;
		display: flex;
		border-bottom: 2rpx solid rgba(0, 0, 0, 0.1);
	}

	.item_left {
		width: 70%;
		padding: 10rpx
	}

	.item_left_text {
		// height: 125rpx;
		line-height: 40rpx;
		text-indent: 2rem;
		font-weight: 500;
		font-size: 24rpx;
	}

	.item_left_time {
		font-size: 24rpx;
		text-align: right;
	}

	.item_right {
		width: 30%;
		padding: 10rpx 0 10rpx 0;
		display: flex;
		justify-content: center;
	}

	.img {
		width: 60%;
		height: auto;
	}
</style>